(function() {

	Nokia.extend(Nokia.device,
		{

			setRightSoftkeyLabel: function(message, callback) {
				if (window.menu && window.menu.setRightSoftkeyLabel) {
					window.menu.setRightSoftkeyLabel(message, callback);
				}
			},

			setLeftSoftkeyLabel: function(message, callback) {
				if (window.menu && window.menu.setLeftSoftkeyLabel) {
					window.menu.setLeftSoftkeyLabel(message, callback);
				}
			},

			vibrate: function(vibraval, vibratime) {
				if (document && document.embeds && document.embeds[0]) {
					var sysinfo = document.embeds[0];
					vibraval = vibraval || 50;
					vibraval = (vibraval >= 100) ? 100 : 50;
					vibratime = vibratime || 25;

					if (sysinfo && sysinfo.startvibra) {
						sysinfo.startvibra(vibratime, vibraval);
					}
				}
			},

			getDeviceImages: function(callback) {
				var instance = this;

				try {

					if (window.device) {

						var so = device.getServiceObject("Service.MediaManagement", "IDataSource");

						var criteria = {
							Type: 'FileInfo',

							Filter: {
								FileType: 'Image'
							},

							Sort: {
								Key: 'FileSize'
							}
						};

				        so.IDataSource.GetList(criteria,
							function(transId, eventCode, result) {
						        var iterator = result.ReturnValue,
									i = 0,
									images = [];

						        iterator.reset();

					        	while ((item = iterator.getNext()) != undefined) {
									images.push(item);
								}

					        	if (callback) {
									callback(images);
								}
				        	}

			        	);

					} else {
						callback.apply(instance, [[]]);
					}

				} catch (e) {
					callback.apply(instance, [[]]);
				}

			}

		}
	);
})();